import { getDatailList } from '@/api'

export default {
    state: {
        detailListData:{},//商品详情
    },
    mutations: {
        GETDATAILLIST(state,detailListData){
            state.detailListData = detailListData
        }
    },
    actions: {
        // 获取商品数据
        async getDatailListData({ commit }, id) {
            
            let result = await getDatailList(id)
            // console.log(result.data)
            if(result.code == 200){
                commit('GETDATAILLIST',result.data)
            }
        }
    },
    getters: {
        // 价格
        price(state){
            return state.detailListData.price 
        },
        // 属性
        spuSaleAttrList(state){
            return state.detailListData.spuSaleAttrList  || []
        },

        skuInfo(state){
            return state.detailListData.skuInfo || {}
        }
        

    }
}